# include "XMLDealState.h"
# include <iostream>

ZDSJ::State::State(): State(ZDSJ::Nothing){

}

ZDSJ::State::State(ZDSJ::Deal_State _state): m_state(_state), m_last_state(ZDSJ::Nothing){

}

void ZDSJ::State::operator=(ZDSJ::Deal_State _state){
    if(this->m_state == _state){
        return;
    }
    this->m_last_state = this->m_state;
    this->m_state = _state;
}

void ZDSJ::State::setCallBack(ZDSJ::Deal_State _state, std::function<callbackType> _callback){
    this->m_callback.emplace(std::make_pair(_state, _callback));
}

ZDSJ::Deal_State ZDSJ::State::operator()(){
    *this = this->m_callback.find(this->m_state)->second(this->m_last_state);
    return this->m_state;
}

ZDSJ::State::~State(){

}